home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4479 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  14.9 KB

  1. From: magicsn@birdland.es.bawue.de (Steffen Haeuser)
  2. Path: eisbaer.bb.bawue.de!birdland.es.bawue.de
  3. Newsgroups: comp.sys.amiga.programmer
  4. Message-ID: <64000305731532830000@BIRDLAND>
  5. X-Mailer: fastnet2rfc V2.0 - (tse) Lunqual%MAB@wsb.freinet.de / Tachy@wsb.freinet.de
  6. Organization: Birdland BBS, Dettingen/Teck, South Germany, +49-7021-862428
  7. Content-Type: text/plain; charset=ISO-8859-1
  8. Subject: rtgmaster c2p standard...
  9. Date: 29 Feb 1996 17:14:43
  10.  
  11.  
  12. The RtgMaster c2p Standard
  13. ==========================
  14.  
  15. rtgmaster.library is a soon to be released ASM written Library for
  16. Graphicsboard AND ECS/AGA compatibility in games and demos. It is
  17. NOT a WB Emulation, but contrary to some WB Emulations it is done
  18. in a way that make that things, that demo/game coders need, EASY
  19. TO DO.
  20.  
  21. Among its features, rtgmaster.library (a Beta version is available
  22. from me, MagicSN@birdland.es.bawue.de), supports a standard for
  23. c2p functions. This will used with the rtgmaster call CallRtgC2P.
  24. CallRtgC2P performs a simple "CopyPixelArray" style function for
  25. Graphics Boards (but does not use the OS, instead it directly
  26. accesses the Video Memory, using longword access where possible),
  27. and performs c2p for ECS/AGA. The c2p is choosable from a file
  28. and the c2p function will be loaded during opening the screen.
  29. This file describes how you can change your c2p algorithm so that
  30. it is usable with rtgmaster.library (you can choose the c2p using
  31. the Screenmode Requester of rtgmaster.library).
  32.  
  33. I myself will soon convert two 68020 optimized and two 68040 optimized
  34. c2p functions. I would be very interested in other people converting
  35. other c2p code, especially interested i would be in 1x2, 2x1 and 2x2
  36. stuff (i do not have such stuff up to now...)
  37.  
  38. Now, let's start... i hope this specification satisfies everybody, as
  39. i really tried hard to support EVERYTHING what is usefull for c2p.
  40.  
  41. Primarily our c2p code is ASM code. You code it, assemble it, and put
  42. it to the directory libs:rtgc2p, with the extension .c2p (a
  43. filename could be libs:rtgc2p/040_1.c2p for example).
  44.  
  45. The c2p file has to have the following structure :
  46.  
  47. Byte 1 :
  48.  
  49.   Bit 0 : Supports AGA     256 Colors
  50.   Bit 1 : "        ECS EHB  64 Colors
  51.   Bit 2 : "        ECS      32 Colors
  52.   Bit 3 : "        ECS      16 Colors
  53.   Bit 4 : Supports 68020
  54.   Bit 5 : Supports 68040
  55.   Bit 6 : Supports 68030
  56.   Bit 7 : Supports 68060
  57.  
  58.   Note : Bit 6 is 0 for 68040
  59.   ONLY c2p. Bit 7 is 0 for stuff that does not run on 060 (as 060 is a bit
  60.   incompatible to the usual stuff...). This is ONLY information given to the
  61.   user in the Screenmode-Requester of rtgmaster.library, it won't be checked.
  62.   You specify 1 if something is supported (or if you do not know), 0 if not.
  63. Byte 2 :
  64.  
  65.   Bit 0 : Supports 1x1
  66.   Bit 1 : "        1x2
  67.   Bit 2 : "        2x1
  68.   Bit 3 : "        2x2
  69.   Bit 4 : "        2x4
  70.   Bit 5 : "        4x2
  71.   Bit 6 : "        4x4
  72.  
  73.   If your c2p code is called with a mode it does not support, it should
  74.   simply choose another one that it supports. It should not fail.
  75.  
  76. Byte 3 :
  77.  
  78.   Bit 0 : Supports Interleaved Bitmaps
  79.   Bit 1 : Supports Non-Interleaved Bitmaps
  80.   Bit 2 : Needs Initialization
  81.   Bit 3 : Width has to be divisibly by 32
  82.   Bit 4 : Height has to be divisible by 32
  83.   Bit 5 : Supports "Dirty" flag
  84.   Bit 6 : Needs additional buffer of width * height Bytes
  85.   Bit 7 : Supports c2p'ing rectangles smaller than Fullscreen
  86.  
  87. Byte 4 :
  88.  
  89.   Bit 0 : Supports Scrambled Chunky
  90.   Bit 1 : Suppors hardware-hacks (won't be called on NOT ECS/AGA Planar hardware)
  91.   Bit 2 : Runs asynchrone (returns BEFORE c2p is finished)
  92.   Bit 3 : Runs on PowerPC 680x0 emulation (well, future compatibility :) )
  93.   Bit 4 : Supports Power Amiga Planar Hardware
  94.   Bit 5 : Supports CyberGraphX 3 Planar Modes
  95.  
  96.   Bit 3 currently should be 1, as we do not know this ... grin...
  97.   I added Bit 4 to get sure (if Power Amiga will have Planar Modes left).
  98.   Bit 5 is intended for the case that CyberGraphX 3 AGA uses Planar modes.
  99.  
  100. Byte 5-7 : Nothing
  101. Byte 8-11  : Pointer to a string that describes your code
  102.             (for example "Fast 040 optimized c2p that remembers
  103.             last frame in additional buffer"). Maximum is 255 characters.
  104. Byte 12-15 : Pointer to code for Non-Interleaved Bitmap or 0.
  105. Byte 16-19 : Pointer to code for Interleaved Bitmap or 0.
  106. Byte 20-23 : Pointer to Initialization code or 0.
  107. Byte 24-27 : Pointer to Expunge code or 0.
  108. Byte 28-31 : Length of the .c2p file in Bytes.
  109.  
  110. The initialization code
  111. =======================
  112.  
  113. RtgScreen     in a0.
  114. mode          in d0.
  115.  
  116. RtgScreen is :
  117.  
  118. STRUCTURE RtgScreen,0
  119.   ULONG rs_LibBase        ; Sub-library base for this ID
  120.   UWORD rs_LibVersion     ; Sub-library version for this ID
  121.   UWORD rs_Pad1
  122.   ULONG rs_GraphicsBoard  ; ID
  123.   STRUCT rs_Reserved,20
  124.   ULONG rs_MouseX
  125.   ULONG rs_MouseY
  126.   APTR  rs_c2pcode
  127.   APTR rs_c2pdata
  128.  
  129.   ; and here the information for the specific sublibrary
  130.   ; will be. Look at your includes of rtgmaster.library for
  131.   ; more information. Currently ECS/AGA is the only supported
  132.   ; hardware that provides Planar modes.
  133.  
  134.   LABEL rs_SIZEOF
  135.  
  136. Example for RtgScreenAMI (rtgAMI.library for ECS/AGA) :
  137.  
  138. STRUCTURE RtgScreenAMI,0
  139.   STRUCT rsAMI_Header,rs_SIZEOF
  140.   UWORD rsAMI_Locks
  141.   ALIGNLONG
  142.   ULONG rsAMI_ScreenHandle
  143.   ULONG rsAMI_PlaneSize
  144.   ULONG rsAMI_DispBuf      ;Buffer currently displayed
  145.   ULONG rsAMI_ChipMem1
  146.   ULONG rsAMI_ChipMem2
  147.   ULONG rsAMI_ChipMem3
  148.   STRUCT rsAMI_Bitmap1,40
  149.   STRUCT rsAMI_Bitmap2,40
  150.   STRUCT rsAMI_Bitmap3,40
  151.   LABEL rsAMI_SIZEOF
  152.  
  153.  
  154. You will find a lot of stuff here, that could be useful for
  155. your c2p code... an Intuition Screenhandle, the Planesize of the
  156. Bitmap(s), the number of the Buffer currently displayed, the
  157. chipmem addresses of the three buffers and the three Bitmaps
  158. of the screen (remember, rtgmaster.library supports up to
  159. Triple-Buffering). rsAMI_Header is the Above RtgScreen structure.
  160.  
  161. rb_c2pcode which contains a pointer to the stuff in the choosen
  162. .c2p file in memory. The .c2p file will be loaded to memory during
  163. the OpenRtgScreen call. This indicates, that loading the c2p code
  164. has to be done by EVERY rtg sublibrary that supports planar modes.
  165.  
  166. rb_c2pdata which should contain a pointer to anything you allocated
  167. in the initialization code of your c2p. You are in NOW WAY limited
  168. in what you do in the initialization function (but you should return
  169. the memory to the system during expunge. Expunge will be called as
  170. soon as you do a c2p with mode c2p_Expunge. There won't be a c2p called
  171. then, instead only an expunge will be done and rb_c2pdata will be set
  172. to 0. Initialization will be called if a c2p is called and rb_c2pdata
  173. is 0). On any way Expunge should free the memory of your c2p code
  174. (rb_c2pcode), so a c2p with mode c2p_Expunge should be called for ANY
  175. application before quit. (so EVERY rtgmaster c2p has an expunge, but
  176. NOT every one has an initialization, as loading the function is done
  177. by rtgmaster itself...)
  178.  
  179. Remember : Normally RtgScreenAMI is a private structure to rtgmaster.library,
  180. but you are allowed to use it in c2p functions...
  181.  
  182. The modes : (as defined in include:rtgmaster/rtgmaster.i)
  183.  
  184. c2p_1x1 EQU 1
  185. c2p_1x2 EQU 2
  186. c2p_2x1 EQU 3
  187. c2p_2x2 EQU 4
  188. c2p_2x4 EQU 5
  189. c2p_4x2 EQU 6
  190. c2p_4x4 EQU 7
  191. c2p_Best EQU 8
  192. c2p_Fastest EQU 9
  193. c2p_Selected EQU 10
  194.  
  195. These are the modes that have the "dirty" flag set to 0. For certain
  196. c2p algorithms a dirty flag of 1 indicates that not all 32 pixel units
  197. of the screen need to be redrawn. Best chooses the mode with the
  198. highest resolution, Fastest the one which performs the fastest c2p,
  199. Selected the one that is selected for this system (this stuff is saved in
  200. envarc:rtgmaster/c2pmode, if for example c2pmode is the string c2p_1x1,
  201. then 1x1 with "dirty" set to 0, will be used). BTW, the used c2p function
  202. (its path) is saved in envarc:rtgmaster/c2p. This is a GLOBAL configuration
  203. for your system.
  204.  
  205. c2p_1x1D EQU 11
  206. c2p_1x2D EQU 12
  207. c2p_2x1D EQU 13
  208. c2p_2x2D EQU 14
  209. c2p_2x4D EQU 15
  210. c2p_4x2D EQU 16
  211. c2p_4x4D EQU 17
  212. c2p_BestD EQU 18
  213. c2p_FastestD EQU 19
  214. c2p_SelectedD EQU 20
  215.  
  216. The same, only with "Dirty" set to 1. If a c2p does not support "dirty" flags,
  217. "dirty" is ignored.
  218.  
  219. And, last, but not least :
  220.  
  221. c2p_Expunge EQU 21
  222.  
  223. If the program wants a mode that is not available, use another similar
  224. mode. Do not fail the program because a mode is not found. But return
  225. a c2p_err_Wrong_Pixelmode anyways.
  226.  
  227. The Expunge function
  228. ====================
  229.  
  230. RtgScreen in a0.
  231.  
  232. The c2p function itself
  233. =======================
  234.  
  235. You will have to code one or two functions (interleaved/non-interleaved).
  236. If CallRtgC2P does not find the needed function, but only 0 (if you only
  237. did it interleaved, and the RtgScreen is non-interleaved, for example)
  238. the CallRtgC2P fails with a c2p_err_Interleavedmode error and does not
  239. perform c2p. This includes specifiying a "dirty" mode, if the c2p does
  240. not support "dirty" modes.
  241.  
  242. If the user wanted to do a c2p with only part of the display, but your
  243. c2p only supports Fullscreen c2p, CallRtgC2P will return a c2p_err_Windowsize
  244. error (it will check for this at first, for speed issues, so you could try to
  245. do a partially c2p in an application first, and if that fails, recalculate to
  246. do the stuff fullscreen from now on).
  247.  
  248. If you try to do a c2p with the wrong Colordepth, CallRtgC2P will return
  249. a c2p_err_Wrong_Colordepth error and won't do a c2p.
  250.  
  251. If you try to do a c2p with a wrong width/height for c2p functions that
  252. are only for "divisible by 32" stuff, a c2p_err_divisible will be given,
  253. but the code will TRY to do the c2p anyways. But normally this should not
  254. happen, if you do not hack around with rtgmaster, as not fitting Screenmodes
  255. are filtered out by the Screenmoderequester.
  256.  
  257. A c2p_err_hardware will be given if for example you try to do hardware
  258. hacking c2p on other devices than ECS/AGA (but up to now ECS/AGA is
  259. the only supported Planar Hardware on rtgmaster anyways) or other
  260. similar compatibility problems.
  261.  
  262. For internal errors in your c2p (no memory left...) you might
  263. return c2p_err_internal.
  264.  
  265. If everything worked fine, CallRtgC2P will return 0.
  266.  
  267. The errormessages :
  268.  
  269. c2p_err_Interleavedmode EQU 1
  270. c2p_err_Wrong_Colordepth EQU 2
  271. c2p_err_Wrong_Pixelmode EQU 3
  272. c2p_err_Windowsize EQU 4
  273. c2p_err_divisible EQU 5
  274. c2p_err_hardware EQU 6
  275. c2p_err_internal EQU 7
  276.  
  277. And now finally, the specification of the c2p function itself :
  278.  
  279. a0 : Pointer to the chunky data
  280. a1 : Pointer to Bitplane 0
  281. a2 : Pointer to a Byte containing the Dirty Flag
  282. a3 : Pointer to the RtgScreen Structure
  283. d1 : Planesize : (width*height)/8
  284. a5 : Buffer of width*height Bytes, if needed (should be allocated
  285.      in the initialization function, if Byte 3/Bit 6 is 0, you will
  286.      find 0 in a5... you should specify the "Initialization function
  287.      needed" for EVERY c2p that needs this extra buffer, else you will
  288.      get buggy code.
  289. d0 : Modus
  290. a4 : Pointer to a rectangle (like definded in include:graphics/gfx.i)
  291.      indicating which rectangle to handle if you do not want a Fullscreen
  292.      c2p (but remember, not all c2p functions support this feature,
  293.      this could fail...)
  294. d2 : For asynchrone stuff : Exec Signal
  295.  
  296. Providing the correct Bitmap of the three is already handled by
  297. rtgmaster.library, you won't have to bother about it... you should
  298. restore ALL registers, only d0,d1,a0 and a1 might loose their contents
  299. in your c2p.
  300.  
  301. d2 contains an Exec Signal (an ULONG containing a signal bit). For
  302. asynchrone code this signal has to be set as soon as the c2p is
  303. finished. Synchrone code should set the signal at the end of the
  304. function. Do not ignore the signal !!! Even if you have a synchronce
  305. function !!!
  306.  
  307. The function returns 0, if it worked, or an appropriate errorcode, if
  308. not. Sometimes it might even then doing something if there was an
  309. errorcode (look above).
  310.  
  311. Finally, the specification for CallRtgC2P :
  312.  
  313. rtgmaster.library/CallRtgC2P                                rtgmaster.library/CallRtgC2P
  314.  
  315.    NAME
  316.         CallRtgC2P -- Perform c2p for Planar Screens, CopyRtgPixelArray for Chunky Screens
  317.  
  318.    SYNOPSIS
  319.         int CallRtgC2P(RtgScreen,BufAdr,Array,signal,xpos,ypos,width,height,mode)
  320.          D0              A0        A1     A2    D0     D1   D2   D3    D4     D5
  321.  
  322.         int CallRtgC2P(struct RtgScreen *,APTR,APTR,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG)
  323.  
  324.    FUNCTION
  325.         This function will look what the "standard c2p" for the system is up to now
  326.         (the standard c2p can be choose by a future version of the Rtgmaster Screenmode
  327.         requester, the available c2p algorithms are found in libs:rtgc2p, how own c2p
  328.         algorithms can be added to the system will be explained in the documentation
  329.         of the first version of rtgmaster.library that actually supports CallRtgC2P).
  330.         The function will, if the display is a Planar one, convert the Chunky Data in
  331.         Array to Planar using the choosen c2p algorithm, and display it in the choosen
  332.         Buffer. For Chunky Displays it will instead do the same as CopyRtgChunkyPixel.
  333.         This way a very easy possibility to support both AGA and Graphics Boards without
  334.         having to do "special versions" will be available, if one uses a Fastram Buffer.
  335.  
  336.         I am still looking for c2p algorithms for this function !!! All used c2p algorithms
  337.         should support AGA and additional, it would be fine, if they supported
  338.         1x1,1x2,2x1 and 2x2. If you have fine c2p algorithms, mail me
  339.         (MagicSN@birdland.es.bawue.de).
  340.  
  341.         NOTE : The Array should EXACTLY be as big as specified with Left, Top, Width
  342.         and Height... it should *NOT* be bigger. Up to now the c2p i have do not
  343.         support the feature to do less then fullscreen...
  344.  
  345.         NOTE: Currently you *HAVE TO* use xpos=0 ypos=0 width=<max x> height=<max y>
  346.         Maybe this will change in the future !!!!!!!!!!!!!!
  347.  
  348.         NOTE: Some c2p algorithms might do NOTHING in certain colour depths, chunky modes
  349.         or for interleaved bitmaps. Be careful about this. If the c2p works,
  350.         this function returns 0, otherwise an errorcode.
  351.  
  352.         Principially it COULD support 256, 64 (EHB), 32 or 16 colors and 1x1, 1x2, 2x1,
  353.         2x2,4x2,2x4 and 4x4 (look at the includes). It is also possible to choose the
  354.         FASTEST AVAILABLE, the BEST AVAILABLE mode or the mode that was selected from
  355.         the user as standard mode for his system, using the Screenmode Requester.
  356.  
  357.         Before quitting the program you should call this function with a mode
  358.         of c2p_Expunge to free used memory in initializations.
  359.  
  360.         If the user did not specify a standard c2p, this function will use the fastest
  361.         available mode.
  362.  
  363.         The signal indicates (for asynchrone c2p) that the c2p has done. For synchrone
  364.         ones it is set after quitting the function.
  365.  
  366.         In mode you specify which c2p mode to use.
  367.  
  368.         For Graphics Boards, ALWAYS 1x1 is used.
  369.  
  370.         IMPLEMENTED WITH SUBLIBRARIES WITH AT LEAST VERSION 2.0 (none up to now...)
  371.  
  372.    INPUTS
  373.         RtgScreen - The RtgScreen to use.
  374.         BufAdr - The address of the buffer to use
  375.         Array - The fastram buffer
  376.         Left - The x position on the Bitmap of RtgScreen where to put the stuff
  377.         Top - The y position
  378.         Width - The Width of the stuff
  379.         Height - The Height of the stuff
  380.  
  381.    SEE ALSO
  382.